package com.demo.Controller;

import com.demo.Service.NewsService;
import com.demo.common.MessageUtils;
import com.demo.entity.News;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/news")
public class NewsController {
    @Autowired
    NewsService newsService;

    @PostMapping
    public MessageUtils<?> InsertUse(@RequestBody News news) {

        news.setTime(new Date());

        return newsService.addNews(news);
    }
}
